<?php
namespace Admin\Controller;
use Admin\Controller\AdminController;
class ContactController extends AdminController{
	public function _empty(){
		header("HTTP/1.0 404 Not Found");
		$this->display('Public:404');
	}
	public function index(){
		$where["status"]=array("NEQ","-1");
		$count = M('About')->count();// 查询满足要求的总记录数
		$Page = new \Think\Page($count,20);// 实例化分页类 传入总记录数和每页显示的记录数(25)
		$show = $Page->show();// 分页显示输出
		// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
		$list=M('Contact')->where($where)->order('add_time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('list',$list);// 赋值数据集
		$this->assign('page',$show);// 赋值分页输出
		$this->display();		
	}
	/**
	 * 查看详情
	 */
	public function info(){
		$where['id']=I('id');
		$list=M('Contact')->where($where)->select();
		$this->assign('list',$list);
		$this->display();
		//查看详情后修改状态为已读
		$data['status']=1;
		$list1=M('Contact')->where($where)->save($data);
	}
	public function delete(){
    	$where['id']=I("id","");
		if(!empty($where['id'])){
			$list=M('Contact')->where($where)->find();			
				$res=M('Contact')->where($where)->delete();
				if($res){
					$this->success('删除成功',U('Contact/index'));
				}else{
					$this->error('删除失败');
				}
		} 
    }




}